# migrate_cookie.py
from pathlib import Path
from crypto import encrypt_to_txt, generate_key, save_key

# 生成密钥（如果还没有密钥文件）
key_path = Path("secret.key")
if not key_path.exists():
    key = generate_key()
    save_key(key, key_path)
else:
    key = key_path.read_bytes()

plain = Path("cookie.txt").read_text(encoding="utf8")
encrypt_to_txt(plain, Path("cookie.bin"), key)
print("cookie.bin与secret.key已生成，请删除 cookie.txt")